<!DOCTYPE html>
<html lang="en">
<head>
  <meta charset="UTF-8">
  <title>Title</title>
</head>
<body>
<script>
  class Father {
    constructor(x, y) {
      this.x = x;
      this.y = y;
    }
    sum() {
      console.log(this.x + this.y);
    }
  }

  class Son extends Father {
    constructor(x, y) {
      super(x, y);  //作用是调用father构造器，如果不写这句话，son1.sum()会报错，因为其实x,y是写到Father里的，sum调用Father的属性
    }
  }

  var son1 = new Son(100, 200);
  son1.sum();// => 300

</script>
</body>
</html>